package com.china.great.system.controller;

import com.china.great.system.common.CommonResultUtil;
import com.china.great.system.entity.Blog;
import com.china.great.system.entity.Log;
import com.china.great.system.service.LogService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Liu HongYang
 * @DateTime: 2020/5/12 10:12 下午
 * @Description: TODO
 */
@RestController
@Api("日志相关的api")
@RequestMapping("/api/v1")
public class LogController {

    @Autowired
    private LogService logService;

    @RequestMapping(value = "/getLogList", method = RequestMethod.GET)
    @ApiOperation(value="获取列表")
    public Object getList(@RequestParam(value="pageSize", defaultValue="20") int pageSize,
                          @RequestParam(value="pageNum", defaultValue="1") int pageNum){
        PageInfo list = logService.getList(pageSize,pageNum);
        return CommonResultUtil.success(list);
    }

    @RequestMapping(value = "/insertLog", method = RequestMethod.POST)
    @ApiOperation(value="增加日志")
    public Object insert(@RequestBody Log log){
        int i = logService.insert(log);
        if (i > 0){
            return CommonResultUtil.success(i);
        }
        return CommonResultUtil.err(i);
    }

}
